const { createProxyMiddleware } = require('http-proxy-middleware')
const WebpackDevServer = require('webpack-dev-server')

/**
 *
 * @param {WebpackDevServer} devServer
 */
function setProxy(devServer) {
  devServer.app.use(
    '/api',
    createProxyMiddleware({
      target: 'http://10.40.7.74',
      changeOrigin: true,
      pathRewrite: {
        '^/api/': '/',
      },
    })
  )
}

module.exports = { setProxy }
